﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XLua;

[LuaCallCSharp]
public class LuaBehaviour : MonoBehaviour {

    LuaTable _bindingTable = null;
    private Action luaStart = null;
    private Action luaOnDestory = null;

    public LuaTable bindingTable {
        get {
            return _bindingTable;
        }
        set {
            value.Get("_start", out luaStart);
            value.Get("_onDestroy", out luaOnDestory);

            _bindingTable = value;
        }
    }

    void Awake() {

    }

	// Use this for initialization
	void Start () {
        if (luaStart != null) {
            luaStart();
        }
	}
	
	// Update is called once per frame
	void Update () {
		
	}

    private void OnDestroy()
    {
        if (luaOnDestory != null)
        {
            luaOnDestory();
        }
        luaOnDestory = null;
        luaStart = null;
        _bindingTable = null;
    }
}
